function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

//用ajax进行数据添加
function addOutline(id){
	var path = "../AddOutline.action";
	var claContent = $("#claContent").val(); //上课内容
	var teaAims = $("#teaAims").val();	//教学目的
	var knowledge = $("#knowledge").val();	//主要知识点
	
	var claNum = $("#claNum").val();
	
	if(iStar == 0){
		$("#ms").html("<font color=red>请选择难易程度！</font>");
		$.dialog.tips('请选择难易程度！',3,'alert.gif');
	}else{
		$.ajax({
		      type: "post",
		      url: path,
		      cache: false,
		      dataType: "json",
		      data: "claContent="+encodeURI(encodeURI(claContent))+
		      "&teaAims="+encodeURI(encodeURI(teaAims))+
		      "&knowledge="+encodeURI(encodeURI(knowledge))+
		      "&difficulty="+iStar+
		      "&claNum="+claNum+
		      "&id="+id,
		      
		      //发送数据之前
		      beforeSend: function(){$.dialog.tips('正在添加数据...',3,'loading.gif');},
		      //complete: function(){},
		      success: function(result){
		    	  if(result[0].flag == 1){
		    		  $.dialog.tips('添加成功！',3,'success.gif');
		    		  $("#ms").html("已新增<font color=red>"+result[0].count+"</font>次课");
		    	  }else if(result[0].flag == 2){
		    		  $.dialog.tips('您好，添加失败，请及时联系管理员处理！',3,'error.gif');
		    		  $("#ms").html("您好，添加失败，请及时联系管理员处理！");
		    	  }else{
		    		  $("#ms").html("<font color=red>新增课程大纲已达课次数上限，不可再添加！</font>");
		    		  $.dialog.tips('新增课程大纲已达课次数上限，不可再添加！',3,'alert.gif');
		    	  }
		      }
		});
	}
}

function updateOutline(id){
	var path = "../ModifyOutline.action";
	var claContent = $("#claContent").val(); //上课内容
	var teaAims = $("#teaAims").val();	//教学目的
	var knowledge = $("#knowledge").val();	//主要知识点
	
	var claNum = $("#claNum").val();
	var oStar = document.getElementById("star");
	var aLi = oStar.getElementsByTagName("li");
	iStartemp=0;
	for (i = 0; i < aLi.length; i++){
			if(aLi[i].className == "on")
				{
                      iStartemp++;				
				}
			
		}
	if(iStartemp == 0){
		$("#ms2").html("<font color=red>请选择难易程度！</font>");
		$.dialog.tips('请选择难易程度！',3,'alert.gif');
	}else{
		$.ajax({
		      type: "post",
		      url: path,
		      cache: false,
		      dataType: "json",
		      data: "claContent="+encodeURI(encodeURI(claContent))+
		      "&teaAims="+encodeURI(encodeURI(teaAims))+
		      "&knowledge="+encodeURI(encodeURI(knowledge))+
		      "&difficulty="+iStartemp+
		      "&claNum="+claNum+
		      "&id="+id+
		      "&type="+encodeURI(encodeURI('modify')),
		      
		      //发送数据之前
		      beforeSend: function(){$.dialog.tips('正在修改数据...',3,'loading.gif');},
		      //complete: function(){},
		      success: function(result){
		    	  if(result[0].flag == 1){
		    		  $.dialog.tips('修改成功！',3,'success.gif');
		    	  }else if(result[0].flag == 2){
		    		  $.dialog.tips('您好，修改失败，请及时联系管理员处理！',3,'error.gif');
		    		  $("#ms2").html("您好，修改失败，请及时联系管理员处理！");
		    	  }else{
		    		  $("#ms2").html("<font color=red>新增课程大纲已达课次数上限，不可再添加！</font>");
		    		  $.dialog.tips('新增课程大纲已达课次数上限，不可再添加！',3,'alert.gif');
		    	  }
		      }
		});
	}
}
//清空
function resetgo(){
	$("#claContent,#teaAims,#knowledge").val("");
	$.dialog.tips('已清空！',1,'confirm.gif');
}
